package com.want.api.blog;

import com.want.annotation.WantClient;
import com.want.model.dto.Result;
import com.want.req.base.PageReqDto;
import com.want.req.blog.dto.CreateBlogDto;
import com.want.req.blog.dto.ListBlogReqDto;
import com.want.req.blog.dto.PoolBlogDto;
import com.want.req.blog.dto.UpdateBlogDto;
import com.want.resp.base.PageResp;
import com.want.resp.blog.dto.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @author WangZhiJian
 * @since 2021/12/7 0007
 */
@WantClient(value = "blogApi",serviceName = "blog-service-v1",context = "blog-service-v1",path = "blog") //,uri = "http://localhost:8082"
public interface BlogApi {
    @GetMapping("{id}")
    public Mono<Result<BlogDto>> blog(@PathVariable("id")Integer id);

    @PostMapping("goodBlog")
    public Mono<Result<Integer>> goodBlog(@RequestBody PoolBlogDto poolBlogDto);

    @PostMapping("/delete")
    public Mono<Result<Integer>> delete(@RequestBody List<Integer> idList);

    @PostMapping("createBlog")
    public Mono<Result<Integer>> createBlog(@RequestBody CreateBlogDto createBlogDto);

    @GetMapping(value = "listAll",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<BlogDto> listAll();

    @PostMapping(value = "listBlog")
    public Mono<Result<PageResp<BlogDto>>> listBlog(@RequestBody PageReqDto<ListBlogReqDto> pageReqDto);

    @GetMapping(value = "listAllBlogTag")
    public Mono<Result<PageResp<BlogTagDto>>> listAllBlogTag();

    @GetMapping(value = "listAllBlogType")
    public Mono<Result<PageResp<BlogTypeDto>>> listAllBlogType();

    @PostMapping("updateBlog")
    public Mono<Result<Integer>> updateBlog(@RequestBody UpdateBlogDto updateBlogDto);

    @ApiOperation(value = "获取一年内的文章贡献数和日期", notes = "获取一年内的文章贡献数和日期")
    @GetMapping("/getBlogContributeCountAndDates")
    public Mono<BlogMetaDataNameAndCountRespDto> getBlogContributeCountAndDates() ;

    @ApiOperation(value = "获取每个分类下文章数目", notes = "获取每个分类下文章数目")
    @GetMapping(value = "/getBlogCountByBlogSort")
    public Mono<List<SimpleBlogMetaDataNameAndCountDto>> getBlogCountByBlogSort() ;

    @PostMapping("blogType/add")
    public Mono<Result<BlogTypeDto>> addBlogType(@RequestBody BlogTypeDto blogTypeDto);
    @PostMapping("blogType/delete")
    public Mono<Result<List<Integer>>> deleteBlogType(@RequestBody List<Integer> idList);
    @PostMapping("blogType/update")
    public Mono<Result<BlogTypeDto>> updateBlogType(@RequestBody BlogTypeDto blogTypeDto);

    @PostMapping("blogTag/add")
    public Mono<Result<BlogTagDto>> addBlogTag(@RequestBody BlogTagDto blogTagDto);

    @PostMapping("blogTag/delete/")
    public Mono<Result<List<Integer>>> deleteBlogTag(@RequestBody List<Integer> id);

    @PostMapping("blogTag/update")
    public Mono<Result<BlogTagDto>> updateBlogTag(@RequestBody BlogTagDto blogTagDto);

    @ApiOperation(value = "获取每个标签下文章数目", notes = "获取每个标签下文章数目", response = String.class)
    @GetMapping(value = "/getBlogCountByBlogTag")
    public Mono<List<SimpleBlogMetaDataNameAndCountDto>> getBlogCountByBlogTag() ;

    @GetMapping("blog/getContent/{id}")
    public Mono<Result<String>> getContent(@PathVariable("id") Integer id);
}
